package 第1节循环语句;

public class LianXi04 {
    public static void main(String[] args) {
                /*
           k    i       j
    *     -4    1       1
   * *    -3    2      1 2
  *   *   -2    3     1 2 3
 *     *  -1    4    1 2 3 4
*       *  0    5   1 2 3 4 5
 *     *   1    6    1 2 3 4
  *   *    2    7     1 2 3
   * *     3    8      1 2
    *      4    9       1
    j = 1   i == j   10 - i = j
        */
        for (int i = 1; i <= 9; i++) {
            for (int k = 1; k <= Math.abs(i - 5); k++) {
                System.out.print(" ");
            }
            for (int j = 1;j <= i && j <= 10 - i;j++) {
                if (j == 1 || j == i || i + j == 10) {
                    System.out.print("*" + " ");
                } else {
                    System.out.print(" " + " ");
                }
            }
            System.out.println();
        }
    }
}
